package com.example.mongodemo;

import com.example.mongodemo.bean.LgResumeDatas;
import com.example.mongodemo.dao.LgResumeDao;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@SpringBootApplication
public class MongoDemoApplication {

    public static void main(String[] args) {
//        SpringApplication.run(MongoDemoApplication.class, args);

        ApplicationContext applicationContext  = SpringApplication.run(MongoDemoApplication.class,args);
        LgResumeDao resumeDao = applicationContext.getBean("lgResumeDao",LgResumeDao.class);
        LgResumeDatas  resume  = new LgResumeDatas();
        resume.setName("wangwu");
        resume.setCity("北京");
        Date date = null;
        String  dateStr = "yyyy-MM-dd hh:mm:ss";
        SimpleDateFormat simpleDateFormat  = new SimpleDateFormat(dateStr);
        try {
            date = simpleDateFormat.parse("2003-11-02 11:13:14");
        } catch (ParseException e) {
            e.printStackTrace();
        }
        resume.setBirthday(date);
        resume.setExpectSalary(28000);
        resumeDao.save(resume);
        System.out.println("resume="+resume);

        LgResumeDatas  resume2  =resumeDao.findFirstByName("wangwu");
        System.out.println(resume2);
    }

}
